from PySide6.QtWidgets import QWidget, QPushButton,QScrollArea,QVBoxLayout
from PySide6.QtCore import Signal, Slot, Property, Qt, QObject
from PySide6.QtGui import QCloseEvent
import Global

class My_Area(QWidget):
    def __init__(self, parent=None):
        super().__init__(parent)
        # 主窗口 layout
        self.setLayout(QVBoxLayout(self))
        
        # 主窗口部件
        self.area = QScrollArea()
        self.layout().addWidget(self.area)
        self.resize(300, 200)
        
    # # 重写尺寸变化事件，记录用户调整后的尺寸
    # def resizeEvent(self, event):
    #     self.saved_size = self.size()  # 保存当前尺寸
    #     super().resizeEvent(event)

    # 重写关闭事件
    def closeEvent(self, event: QCloseEvent):
        parent_widget = self.parentWidget()
        if parent_widget:
            self.hide()
            print("【子窗口】已隐藏")
            parent_widget.show()
            print("【主窗口】已显示")
        else:
            print("【警告】未找到父窗口（主窗口）")

        event.ignore()